Skip to content

feat: add --context flag to set model context window - #2

Merged
outofcoffee merged 1 commit into
mainfrom
worktree-context-size
Jun 23, 2026
Merged

feat: add --context flag to set model context window#2
outofcoffee merged 1 commit into
mainfrom
worktree-context-size

Conversation

@outofcoffee

@outofcoffee outofcoffee commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

Add a --context/-c flag to oc-config add for setting a model's context window, with forgiving parsing of human-friendly sizes.

Summary

  • New --context/-c flag on oc-config add writes each added model's window as limit.context in the opencode config.
  • Lenient parsing: decimal suffixes (k/m/g/t), absolute counts (200000), fractions (1.5m), and stray commas, underscores, whitespace, or a trailing tokens word all parse as you'd expect.
  • Existing limit keys (e.g. output) are preserved when context is merged in.
  • --providers loses its -c short alias (long form only) so -c can serve --context.
  • README and both llama.cpp guides document the flag; the guides show matching opencode's window to the server's --ctx-size.
  • Unit tests for the parser, the applier, and the CLI path; total coverage rises from ~77% to ~89%.

Implementation details

Suffixes are decimal (128k = 128,000 tokens), which matches how context windows are usually quoted, rather than binary (1024). Context is applied to every model added in the invocation by merging a limit map onto each entry, so it composes with the existing deep-merge write path without clobbering sibling limit keys.

@outofcoffee outofcoffee added documentation Improvements or additions to documentation enhancement New feature or request labels Jun 22, 2026
Adds an `--context`/`-x` flag to `oc-config add` that records each added
model's context window as `limit.context` in the opencode config. Parsing
is lenient: human suffixes (k/m/g/t, decimal), absolute counts, fractions,
commas/underscores/whitespace, and a trailing "tokens" word are all
accepted.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@outofcoffee
outofcoffee force-pushed the worktree-context-size branch from 405b58e to 126b429 Compare June 22, 2026 16:46
@outofcoffee
outofcoffee merged commit 71c0858 into main Jun 23, 2026
1 check passed
@outofcoffee
outofcoffee deleted the worktree-context-size branch June 23, 2026 06:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant